package za.ac.wits.was.research;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.Transient;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import za.ac.wits.was.user.model.AcademicStaff;

/**
 *
 * @author Salman Noor : School of Electrical and Information Engineering
 * @Copyright: Wits University 2013 - All Rights Reserved
 * @email: salmannoor74415@gmail.com
 * @License: BSD License (http://www.linfo.org/bsdlicense.html)
 */
@Entity
@Table(name = "research_allocations")
public class ResearchAllocations implements Serializable {
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "research_allocation_id")
    private Long research_allocation_id;
    
    @ManyToOne
    @JoinColumn(name = "user_id")
    private AcademicStaff academic_staff_member;
    
    @Column(name = "research_topic")
    private String research_topic;
    
    @Column(name = "research_description",columnDefinition = "TEXT")
    private String research_description;
    
    @Column(name = "research_hours")
    private Integer research_hours;
    
    @Column(name = "research_sabbatical")
    private Boolean research_sabbatical;
    
    @Column(nullable = false)
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date research_start_date;
    
    @Column(nullable = false)
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date research_end_date;
    
    @Column(nullable = true)
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date sabbatical_start_date;
    
    @Column(nullable = true)
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date sabbatical_end_date;

    @Column(name = "pending")
    private Boolean pending;
    
    @Column(name = "approved")
    private Boolean approved;
    
    @Transient
    private String status;
    
    public Long getResearch_allocation_id() {
        return research_allocation_id;
    }

    public void setResearch_allocation_id(Long research_allocation_id) {
        this.research_allocation_id = research_allocation_id;
    }
    @JsonProperty("academic_staff_member")
    public AcademicStaff getAcademic_staff_member() {
        return academic_staff_member;
    }
    @JsonIgnore
    public void setAcademic_staff_member(AcademicStaff academic_staff_member) {
        this.academic_staff_member = academic_staff_member;
    }

    public String getResearch_topic() {
        return research_topic;
    }

    public void setResearch_topic(String research_topic) {
        this.research_topic = research_topic;
    }

    public String getResearch_description() {
        return research_description;
    }

    public void setResearch_description(String research_description) {
        this.research_description = research_description;
    }

    public Integer getResearch_hours() {
        return research_hours;
    }

    public void setResearch_hours(Integer research_hours) {
        this.research_hours = research_hours;
    }

    public Boolean getResearch_sabbatical() {
        return research_sabbatical;
    }

    public void setResearch_sabbatical(Boolean research_sabbatical) {
        this.research_sabbatical = research_sabbatical;
    }

    public Date getResearch_start_date() {
        return research_start_date;
    }

    public void setResearch_start_date(Date research_start_date) {
        this.research_start_date = research_start_date;
    }

    public Date getResearch_end_date() {
        return research_end_date;
    }

    public void setResearch_end_date(Date research_end_date) {
        this.research_end_date = research_end_date;
    }

    public Date getSabbatical_start_date() {
        return sabbatical_start_date;
    }

    public void setSabbatical_start_date(Date sabbatical_start_date) {
        this.sabbatical_start_date = sabbatical_start_date;
    }

    public Date getSabbatical_end_date() {
        return sabbatical_end_date;
    }

    public void setSabbatical_end_date(Date sabbatical_end_date) {
        this.sabbatical_end_date = sabbatical_end_date;
    }

    public Boolean getPending() {
        return pending;
    }

    public void setPending(Boolean pending) {
        this.pending = pending;
    }

    public Boolean getApproved() {
        return approved;
    }

    public void setApproved(Boolean approved) {
        this.approved = approved;
    }
    @JsonProperty("status")
    public String getStatus() {
        if (this.pending) {
            this.status = "Pending";
        } else {
            if (this.approved) {
                this.status = "Approved";
            } else {
                this.status = "Declined";
            }
        }
        return status;
    }
    
    @JsonIgnore
    public void setStatus(String status) {
        this.status = status;
    }
    
    
}
